#include "cx_sound.h"
#include "vmmm.h"
//#include "cx_platform_base.h"
#include "vmgraph.h"

QVOID* pSoundManager;

extern VMUINT8* cx_sound_load(QVOID* pSoundManager, QINT resid, QINT* len);

QVOID cx_sound_endplaymidi(QINT handle, QINT event)
{
	// nothing
}

QINT cx_sound_playmidi(QINT resid, QINT repeat)
{
	return vm_midi_play(resid, repeat, cx_sound_endplaymidi);
}

QINT cx_sound_playmidibybytes(QUINT *midibuf, QINT len, QINT repeat)
{
	return vm_midi_play_by_bytes((VMUINT8 *)midibuf, len, repeat, cx_sound_endplaymidi);
}

QBYTE* cx_sound_resprovider(QINT resid, QINT* len)
{
	return cx_sound_load(pSoundManager, resid, len);
}

QVOID cx_sound_loadmidiresource(QVOID* soundmanager)
{
	pSoundManager = soundmanager;
	vm_reg_res_provider(cx_sound_resprovider);
}

QVOID cx_sound_stopmidi(QINT handle)
{
	vm_midi_stop(handle);
}

QINT cx_sound_playvibrator()
{

	vm_vibrator_once();
	return QTRUE;
}
